'''
# Coding:utf-8
# Project: online-exam
# Author: rtf
# Time: 2022-07-27 14:32:58
# FileName: recursion_tree.py
# Software: PyCharm
'''


def get_list(parent_id, datas, parent_column_name="parent_id", next_parent_column_name="id"):
    result = list()
    for x in datas:
        if str(x.get(parent_column_name)) == str(parent_id):
            next_pid = x.get(next_parent_column_name)
            x['children'] = get_list(next_pid, datas, parent_column_name, next_parent_column_name)
            result.append(x)
    return result